package com.hsj.springai.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class PayAspect {
    @Before("execution(public void com.hsj.springai.config.AServiceImpl.pay(..))")
    public void beforeNotify() {
        System.out.println("@Before前置通知");
    }

    @After("execution(public void com.hsj.springai.config.AServiceImpl.pay(..))")
    public void afterNotify() {
        System.out.println("@After后置通知");
    }

    @AfterReturning("execution(public void com.hsj.springai.config.AServiceImpl.pay(..))")
    public void afterReturn() {
        System.out.println("@AfterReturn返回通知");
    }

    @AfterThrowing("execution(public void com.hsj.springai.config.AServiceImpl.pay(..))")
    public void afterThrow() {
        System.out.println("@afterThrow异常通知");
    }

    @Around("execution(public void com.hsj.springai.config.AServiceImpl.pay(..))")
    public Object aroundNotify(ProceedingJoinPoint proceedingJoinPoint)throws Throwable{
        Object retValue = null ;
        System.out.println("@Around 环绕通知aaaaa");
        retValue = proceedingJoinPoint.proceed();
        System.out.println("@Around 环绕通知bbbbb");
        return retValue;
    }
}
